<script setup lang="ts" name="OperlogDetail">
const { sys_oper_type, sys_common_status } = useDict("sys_oper_type", "sys_common_status");

const emit = defineEmits(['closeDialog']);

const props = defineProps({
  row: {
    default: null,
  },
  title: {
    type: String,
    default: false,
  }
});
const open = ref(false);

const form = ref<OperlogRecord>({});

/** 获取操作日志详情 */
function getData() {
  form.value = props.row;
  open.value = true;
}

/** 关闭弹窗 */
function closeDialog(refresh: boolean) {
  open.value = false;
  emit("closeDialog", refresh);
}

watch(open, (val) => {
  if (!val) {
    closeDialog(false);
  }
});

getData();
</script>

<template>
  <!-- 操作日志详情对话框 -->
  <el-dialog :title="title" v-model="open" width="700px" append-to-body>
    <div class="detail-form">
      <el-form ref="operlogForm" :model="form" label-width="80px">
        <el-form-item label="系统模块" prop="title">
          {{ form.title }}
        </el-form-item>
        <el-form-item label="操作类型" prop="businessType">
          <dict-tag :options="sys_oper_type" :value="form.businessType" />
        </el-form-item>
        <el-form-item label="登陆信息" prop="operName">
          {{ form.operName }}/{{ form.operIp }}/  {{ form.operLocation }}
        </el-form-item>
        <el-form-item label="请求地址" prop="operUrl">
          {{ form.operUrl }}
        </el-form-item>
        <el-form-item label="请求方式" prop="requestMethod">
          {{ form.requestMethod }}
        </el-form-item>
        <el-form-item label="操作状态" prop="status">
          <dict-tag :options="sys_common_status" :value="form.status" />
        </el-form-item>
        <el-form-item label="操作方法" prop="method" class="item-describe">
          {{ form.method }}
        </el-form-item>
        <el-form-item label="请求参数" prop="operParam" class="item-describe item-content">
          {{ form.operParam }}
        </el-form-item>
        <el-form-item label="返回参数" prop="jsonResult" class="item-describe item-content">
          {{ form.jsonResult }}
        </el-form-item>
        <el-form-item label="异常信息" prop="errorMsg" class="item-describe item-content">
          {{ form.errorMsg }}
        </el-form-item>
        <el-form-item label="操作日期" prop="operTime">
          {{ form.operTime }}
        </el-form-item>
        <el-form-item label="消耗时间" prop="costTime">
          {{ form.costTime }}
        </el-form-item>
      </el-form>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeDialog(false)">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style lang="scss" scoped>

</style>